package cn.autowired.exam.service.impl;

import cn.autowired.exam.entity.TeacherFreeTime;
import cn.autowired.exam.dao.TeacherFreeTimeMapper;
import cn.autowired.exam.service.TeacherFreeTimeService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cq
 * @since 2018-05-25
 */
@Service
public class TeacherFreeTimeServiceImpl extends ServiceImpl<TeacherFreeTimeMapper, TeacherFreeTime> implements TeacherFreeTimeService {

    @Override
    public TeacherFreeTime selectByTeacherIdAndFreeDate(Integer teacherId, String freeDate) {
        TeacherFreeTime teacherFreeTime = selectOne(new EntityWrapper<TeacherFreeTime>()
                .eq(TeacherFreeTime.Field.teacherId, teacherId)
                .eq(TeacherFreeTime.Field.freeDate, freeDate));
        return teacherFreeTime;
    }

    @Override
    public List<TeacherFreeTime> selectByTeacherBetweenDate(Integer teacherId, String startDate, String endDate) {
        List<TeacherFreeTime> teacherFreeTimes = selectList(new EntityWrapper<TeacherFreeTime>()
                .eq(TeacherFreeTime.Field.teacherId, teacherId)
                .between(TeacherFreeTime.Field.freeDate, startDate, endDate));
        return teacherFreeTimes;
    }
}
